package epinions;

import java.io.IOException;

import polarizedMF.Step0_TraditionalMF;
import polarizedMF.Step8a_Ordinal_SVM_Model;
import writeToExcel.WriteRMSEToExcel;
import constants.Constants;
import data.MatrixSize;
import data.Param;

public class Step8a_Ordinal_SVM_Model_epinions {

	public static void main(String[] args) throws IOException {
		double[][] RMSE = new double[6][5];
		double[][] normalPosRMSE = new double[6][5];
		double[][] normalNeuRMSE = new double[6][5];
		double[][] normalNegRMSE = new double[6][5];
		double[][] posRMSE = new double[6][5];
		double[][] neuRMSE = new double[6][5];
		double[][] negRMSE = new double[6][5];
		double normalRMSE = 1.080;
		double[] idealRMSE = new double[6];

		MatrixSize size = new MatrixSize(22166, 296277);
		Param param = new Param((byte) 5, 0.02, 0.4);
		String svm_dataset = Constants.svm_dir + "epinions\\";
		String dataset = Constants.dir + "epinions\\epinions\\";
		String fold = "5";

		String[] epsilons = { "0", "05", "1", "15", "2", "25" };
		double[] eps = {0.0, 0.05, 0.1, 0.15, 0.2, 0.25};
		double margin = 0;

		for (int i = 0; i < 6; i++) {
			String epsilon = epsilons[i];
			double ep = eps[i];
			Step0_TraditionalMF step0 = new Step0_TraditionalMF(dataset,
					ep, fold, size, param);
			normalRMSE = step0.getNormalRMSE();
			idealRMSE[i] = step0.getIdealRMSE();
			
			for (int j = 0; j < 5; j++) {
				if(j == 0){
					Step8a_Ordinal_SVM_Model step8a = new Step8a_Ordinal_SVM_Model(
							svm_dataset, dataset, fold, epsilon, margin + j * 0.5, size, param);
					RMSE[i][j] = step8a.getAllRMSE();
					normalPosRMSE[i][j] = step8a.getNormalPosRMSE();
					normalNeuRMSE[i][j] = step8a.getNormalNeuRMSE();
					normalNegRMSE[i][j] = step8a.getNormalNegRMSE();
					posRMSE[i][j] = step8a.getPosRMSE();
					neuRMSE[i][j] = step8a.getNeuRMSE();
					negRMSE[i][j] = step8a.getNegRMSE();
					System.out
							.println("------------------------------------------------------------------------------------");
				}
				else {
					RMSE[i][j] = RMSE[i][0];
					normalPosRMSE[i][j] = normalPosRMSE[i][0];
					normalNeuRMSE[i][j] = normalNeuRMSE[i][0];
					normalNegRMSE[i][j] = normalNegRMSE[i][0];
					posRMSE[i][j] = posRMSE[i][0];
					neuRMSE[i][j] = neuRMSE[i][0];
					negRMSE[i][j] = negRMSE[i][0];
					System.out
							.println("------------------------------------------------------------------------------------");
				}
			}
		}

		WriteRMSEToExcel writeToExcel = new WriteRMSEToExcel("epinions", fold,
				normalRMSE, idealRMSE, RMSE, posRMSE, neuRMSE, negRMSE);
	}

}
